Avorion Script API Documentation
Entity Callbacks
Note: Callbacks have to be buffered in certain situations and won't happen immediately. When unregistering a callback during a callback, all callbacks that were buffered during the last frame may still be sent, even though they were unregistered.
callback destinationSectorReady(sectorReady)
Executed when the availability state of the destination sector changes. When the sector is loaded into memory, it's set to true. When the sector is unloaded from memory, because there's no player near it, it's set to false.
Parameters
callback onAIStateChanged(entityId, state)
Executed whenever the AI state of the entity changes
Parameters
state The id of the new state
callback onAutoSelected()
Executed when the entity gets selected by the player on the client.
callback onBlockChanged(objectIndex, blockIndex, changeFlags)
Executed whenever the plan of the entity is changed.
Parameters
blockIndex The index of the block
changeFlags The flags of the block changes
callback onBlockDamaged(objectIndex, blockIndex, inflictorId, damage, damageType)
Executed whenever a block object is damaged in the sector. This callback is executed *after* the damage is dealt to the block, and before the block may be destroyed due to damage. Don't remove the block in this callback, this will lead to a crash.
Parameters
blockIndex The index of the damaged block
inflictorId The id of the entity that inflicted the damage
damage The damage that was inflicted to the entity
damageType The type of damage
callback onBlockDestroyed(objectIndex, index, block, lastDamageInflictor, damageSource)
Executed whenever a block of the block object got destroyed This callback is executed *after* the block was destroyed
Parameters
index Index of the block
block The block (as removed from the plan)
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed block
damageSource The source of damage
callback onBlockHealed(objectIndex, blockIndex, damage)
Executed whenever a block of the entity is healed. This callback is executed *before* the healing is done to the block. Don't remove the block in this callback, this will lead to a crash.
Parameters
blockIndex The index of the healed block
damage The damage the entity was healed for
callback onBlockPlanChanged(objectIndex, allBlocksChanged)
Executed whenever the plan of the entity is changed.
Parameters
allBlocksChanged A boolean that indicates whether all the blocks in the block plan have potentially changed
callback onBlocksAdded(objectIndex, wasRepaired, blockIndices)
Executed whenever new block are added to the entity. This callback is executed after the blocks were added.
Parameters
wasRepaired true if the callback was fired because of a repair operation, false otherwise
blockIndices The indices of the added blocks, as variable arguments list
callback onBlocksRemove(objectIndex, blockIndices)
Executed whenever a block will be removed from the plan by building (instead of combat). This callback is executed before the block is removed. IMPORTANT! This only fires on blocks that the player directly chose to be removed. Blocks that get removed because they don't have a connection to the root block any more get signalled after removal by 'onBlocksRemoved'.
Parameters
blockIndices The indices of the removed blocks, as variable arguments list
callback onBlocksRemoved(objectIndex, blockIndices)
Executed whenever a block is removed from the plan by building (instead of combat). This callback is executed after the block is removed.
Parameters
blockIndices The indices of the removed blocks, as variable arguments list
callback onBoardersDefeated(entityId, attackingFaction)
Executed whenever all boarders were defeated
Parameters
attackingFaction The index of the attacking faction
callback onBoardersLand(entityId, attackingFaction, firstLanding)
Executed when boarders land on an entity
Parameters
attackingFaction The index of the attacking faction
firstLanding True if these are the first boarders, false otherwise
callback onBoardingFight(entityId, attackingFaction)
Executed on every round of fighting with boarders
Parameters
attackingFaction The index of the attacking faction
callback onBoardingSuccessful(entityId, oldFactionIndex, newFactionIndex)
Executed whenever an entity was boarded successfully
Parameters
oldFactionIndex The index of the faction that owned the entity before boarding
newFactionIndex The index of the attacking faction that now owns the entity
callback onBreak(objectIndex, plan...)
Executed when the plan of the entity breaks. This callback is executed after the block broke. This callback is expensive, don't register for it if you don't absolutely need it.
Parameters
plan... The plans of the broken off parts
callback onCargoChanged(objectIndex, delta, good)
Executed whenever the cargo of an entity in the sector changes. This callback is executed *after* the cargo was changed on the entity.
Parameters
delta The amount of cargo that changed
good The good that changed
callback onCargoLootCollected(collector, lootIndex, amount, good, owner)
Executed whenever trading good loot gets collected by a player
Parameters
lootIndex The index of the collected loot
amount The amount of goods that were collected
good The good that was inside the loot entity
owner The original owner of the cargo
callback onCollision(objectIndexA, objectIndexB)
Executed whenever two block objects collided in the sector
Parameters
objectIndexB The index of the other colliding object
callback onCraftSeatEntered(entityId, seat, playerIndex, firstPlayer)
Executed whenever a player enters an empty craft or the last player exits it
Parameters
seat The seat index
playerIndex The index of the player that entered the seat
firstPlayer A bool indicating whether the craft's seats were empty before
callback onCraftSeatLeft(entityId, seat, playerIndex, playersRemaining)
Executed whenever a player enters an empty craft or the last player exits it
Parameters
seat The seat index that was previously occupied
playerIndex The index of the player that left the seat
playersRemaining A bool indicating whether there are still players on the craft
callback onCrewChanged(index, delta, profession)
Executed whenever the crew of an entity in the sector changes. This callback is executed *after* the crew was changed on the entity.
Parameters
delta The amount of crewmen that changed
profession The profession of the crew that changed
callback onCrewChanged(index)
Executed whenever the crew of the entity changes. This callback is executed *after* the crew was changed on the entity.
Parameters
callback onCrewLootCollected(collector, lootIndex)
Executed whenever trading good loot gets collected by a player
Parameters
lootIndex The index of the collected loot
callback onDamaged(objectIndex, amount, inflictor, damageSource, damageType)
Executed whenever an entity is damaged in the sector. This callback is executed *before* the damage is dealt.
Parameters
amount The amount of damage that was dealt
inflictor The id of the entity that dealt the damage
damageSource The source of damage
damageType The type of damage
callback onDestroyed(index, lastDamageInflictor)
Executed when the entity was destroyed
Parameters
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed entity
callback onFighterAdded(entityId, squadIndex, fighterIndex, landed)
Executed whenever a fighter is added to the entity
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
landed A boolean whether the fighter landed or got added otherwise
callback onFighterLanded(entityId, squadIndex, fighterId)
Executed whenever a fighter starts from a hangar of the entity
Parameters
squadIndex The index of the squad
fighterId The id of the fighter that landed
callback onFighterRemove(entityId, squadIndex, fighterIndex, started)
Executed whenever a fighter is removed from the entity, before it gets removed
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
started A boolean whether the fighter started or got removed otherwise
callback onFighterRemoved(entityId, squadIndex, fighterIndex, started)
Executed whenever a fighter is removed from the entity, after it got removed
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
started A boolean whether the fighter started or got removed otherwise
callback onFighterStarted(entityId, squadIndex, fighterId)
Executed whenever a fighter starts from a hangar of the entity
Parameters
squadIndex The index of the squad
fighterId The id of the fighter that started
callback onHealed(objectIndex, amount, inflictor)
Executed whenever an entity is healed in the sector. This callback is executed *before* the damage is healed.
Parameters
amount The amount of damage that was healed
inflictor The id of the entity that dealt the damage
callback onHullHit(objectIndex, blockIndex, shooterIndex, damage, location)
Executed whenever a block object is hit by a shot in the sector. This callback is executed *before* the damage is dealt to the object. Don't delete the block that is hit by the shot, this will lead to a crash.
Parameters
blockIndex The index of the block that was hit by the shot
shooterIndex The index of the craft that fired the shot
damage The damage the shot dealt to the object
location The impact location
callback onJump(shipIndex, x, y)
Executed whenever the entity jumps into another sector.
Parameters
x The x coordinate of the target sector
y The y coordinate of the target sector
callback onLootCollected(collector, lootIndex)
Executed whenever loot gets collected by anyone, be it player or AI faction
Parameters
lootIndex The index of the collected loot
callback onMaterialLootCollected(collector, lootIndex, materialType, value)
Executed whenever material loot gets collected by
Parameters
lootIndex The index of the loot that was collected
materialType The type of material contained in the loot
value The amount of material the loot contained
callback onMoneyLootCollected(collector, lootIndex, value)
Executed whenever money loot gets collected by the entity
Parameters
lootIndex The index of the collected loot
value The amount of credits the loot contained
callback onPlanModifiedByBuilding(shipIndex)
Executed whenever the plan of an entity was modified by building, meaning adding or removing blocks.
Parameters
callback onSectorEntered(entityId, x, y)
Executed whenever the entity enters a sector.
Parameters
x Sector X coordinates of the entered sector
y Sector Y coordinates of the entered sector
callback onSelected()
Executed when the entity gets selected by the player on the client.
callback onSetForDeletion(entityId, deletionType)
Executed whenever the entity is to be deleted.
Parameters
deletionType The deletion type
callback onShaftAutomaticLoadingTypeAssign(entityId, shaftIndex, type)
Executed whenever the torpedo type that is automatically loaded into a shaft was assigned
Parameters
shaftIndex The index of the torpedo shaft
type The type of torpedo that now gets automatically loaded
callback onShaftWeaponIndexAssign(entityId, shaftIndex, weaponIndex)
Executed whenever a torpedo shaft was assigned a new weapon index
Parameters
shaftIndex The index of the new torpedo shaft
weaponIndex The new weapon index of the shaft
callback onShieldActivate(entityId)
Executed whenever the entities shield activates
Parameters
callback onShieldDamaged(entityId, amount, damageType, inflictorId)
Executed whenever the entities shield is damaged
Parameters
amount The amount of damage inflicted
damageType The type of damage dealt
inflictorId The id of the entity that inflicted the damage
callback onShieldDeactivate(entityId)
Executed whenever the entities shield deactivates
Parameters
callback onShieldHealed(entityId, amount)
Executed whenever the entities shield is healed
Parameters
amount The amount of damage healed
callback onShieldHit(objectIndex, shooterIndex, damage, location)
Executed whenever an object's shield is hit by a shot in the sector. This callback is executed *before* the damage is dealt to the object.
Parameters
shooterIndex The index of the craft that fired the shot
damage The damage the shot dealt to the object
location The impact location
callback onShotFired(entityId)
Executed whenever the entity fires a shot
Parameters
callback onShotHit(objectIndex, shooterIndex, location)
Executed whenever a block object is hit by a shot in the sector. This callback is executed *before* the damage is dealt to the object.
Parameters
shooterIndex The index of the craft that fired the shot
location The impact location
callback onSquadAdded(entityId, index)
Executed whenever a squad is removed from the entity
Parameters
index The index of the squad
callback onSquadOrdersChanged(entityId, squadIndex, orders, targetId)
Executed whenever the orders of a squad of the entity change
Parameters
squadIndex The index of the squad
orders The orders of the squad
targetId The target assigned to the fighters
callback onSquadRemove(entityId, index)
Executed whenever a squad is removed from the entity, before the squad gets removed
Parameters
index The index of the squad
callback onSquadRemoved(entityId, index)
Executed whenever a squad is removed from the entity, after the squad got removed
Parameters
index The index of the squad
callback onStartDialog(objectIndex)
Executed when a dialog is started.
Parameters
callback onStartFiring(entityId)
Executed whenever the entity starts firing
Parameters
callback onStopFiring(entityId)
Executed whenever the entity stops firing
Parameters
callback onSystemsChanged(shipIndex)
Executed whenever the systems of a ship in the sector changed. This callback is executed *after* the system was changed on the entity.
Parameters
callback onSystemUpgradeLootCollected(collector, lootIndex)
Executed whenever material loot gets collected by
Parameters
lootIndex The index of the loot that was collected
callback onTorpedoAdded(entityId, shaftIndex, torpedoIndex, torpedo)
Executed whenever a torpedo added to the entity
Parameters
shaftIndex The index of the new torpedo shaft (-1 if storage)
torpedoIndex The index of the torpedo
torpedo The torpedo that's added
callback onTorpedoHit(objectIndex, shooterIndex, torpedoIndex)
Executed whenever a block object is hit by a torpedo in the sector. This callback is executed *before* the damage is dealt to the object.
Parameters
shooterIndex The index of the craft that fired the torpedo
torpedoIndex The index of the torpedo that hit the object
callback onTorpedoHullHit(objectIndex, blockIndex, shooterIndex, damage, torpedoIndex)
Executed whenever a block object is hit by a torpedo in the sector. This callback is executed *before* the damage is dealt to the object. Don't delete the block that is hit by the torpedo, this will lead to a crash.
Parameters
blockIndex The index of the block that was hit by the torpedo
shooterIndex The index of the craft that fired the torpedo
damage The damage the torpedo dealt to the object
torpedoIndex The index of the torpedo that hit the object
callback onTorpedoLaunched(entityId, torpedoId)
Executed whenever a torpedo was launched from the entity
Parameters
torpedoId The id of the launched torpedo
callback onTorpedoRemove(entityId, shaftIndex, torpedoIndex)
Executed whenever a torpedo is about to be removed from the entity
Parameters
shaftIndex The index of the new torpedo shaft (-1 if storage)
torpedoIndex The index of the torpedo
callback onTorpedoRemoved(entityId, shaftIndex, torpedoIndex)
Executed whenever a torpedo was removed from the entity
Parameters
shaftIndex The index of the new torpedo shaft (-1 if storage)
torpedoIndex The index of the torpedo
callback onTorpedoShieldHit(objectIndex, shooterIndex, damage, torpedoIndex)
Executed whenever an object's shield is hit by a torpedo in the sector. This callback is executed *before* the damage is dealt to the object.
Parameters
shooterIndex The index of the craft that fired the torpedo
damage The damage the torpedo dealt to the object
torpedoIndex The index of the torpedo that hit the object
callback onTurretDestroyed(turretIndex, shipIndex, lastDamageInflictor)
Executed whenever a turret of the entity was destroyed
Parameters
shipIndex The id of the entity that turret was attached to
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed entity
callback onTurretLootCollected(collector, lootIndex)
Executed whenever turret loot gets collected by the entity
Parameters
lootIndex The index of the collected loot
Callbacks Alliance [Client] Callbacks Alliance [Server] Callbacks Alliance [Server] Callbacks Entity Callbacks Galaxy Callbacks Player Callbacks Player [Client] Callbacks Sector Callbacks Server Callbacks
Command Entity FactionDatabase PlanGenerator Player Sector Server UsableInventoryItem
Boarding BspTree CargoBay ControlUnit DeletionTimer DirectFlightPhysics DockingPositions Durability EnergySystem Engine FighterAI Hangar InteractionText Owner Physics Plan ReadOnlyBoarding ReadOnlyBspTree ReadOnlyCargoBay ReadOnlyControlUnit ReadOnlyDeletionTimer ReadOnlyEnergySystem ReadOnlyEngine ReadOnlyFighterAI ReadOnlyHangar ReadOnlyInteractionText ReadOnlyOwner ReadOnlyPhysics ReadOnlyPlan ReadOnlyShipAI ReadOnlyShipSystem ReadOnlyTorpedoAI [Server] [Client] [Server] [Client] ReadOnlyTorpedoAI [Server] [Client] [Server] [Client] ReadOnlyTorpedoLauncher ReadOnlyTurretBases ReadOnlyVelocity ReadOnlyWeapons ReadOnlyWormHole Shield ShipAI ShipSystem SystemUpgradeLoot Thrusters Torpedo TorpedoAI TorpedoLauncher Turret TurretAI TurretBases Velocity Weapons WormHole
AllianceMember AllianceRank BlockPlan BlockPlanBlock BlockStatistics Box Color ControlUnitSeat CraftDesign Crew CrewMan CrewProfession DebugInfo dvec2 dvec3 dvec4 Entity EntityDescriptor FighterTemplate Format GameSettings HighResolutionTimer Inventory InventoryTurret ivec2 ivec3 ivec4 Language Mail Material Matrix ModManager NamedFormat PlanBspTree PlanetSpecifics PlanGenerationStage PlanPart PlanStyle PlayerId PluralForm Profiler QuadTree Random Rarity Ray ReadOnlyEntity Rect Relation SectorView Seed Sphere SystemUpgradeTemplate Timer Tooltip TooltipLine TorpedoTemplate TradingGood TurretDesign TurretDesignPart TurretTemplate UsableInventoryItem Uuid VanillaInventoryItem vec2 vec3 vec4 Version Weapon
EntityIcon EntityTooltip PlanMesh ReadOnlyIcon ReadOnlyPlanMesh ReadOnlyScriptUI ReadOnlyTooltip ScriptUI
Achievements Alliance [Client] ClientSettings CraftDesignSelectionItem Faction [Client] Galaxy [Client] GalaxyMap GameInput InputWindow InventoryReferenceSelectionItem InventorySelectionItem Keyboard LaserFX Mouse Music Planet Player [Client] PlayerWindow Sector [Client] SelectionItem SoundSource TooltipRenderer TurretDesignSelectionItem
AllianceTab ArrowLine Button [Client] [Client] Button [Client] [Client] CheckBox ComboBox CraftPortrait Frame Hud InventorySelection Label Line ListBox ListBoxEx MapArrowLine MultiLineTextBox NumbersBar Picture PlanDisplayer ProgressBar SavedDesignsSelection ScrollFrame Selection ShipWindow Slider StatisticsBar Tab TabbedWindow TextBox TextField Tree UIArbitraryHorizontalSplitter UIArbitraryVerticalSplitter UIContainer UIElement UIGridSplitter UIHorizontalLister UIHorizontalMultiSplitter UIHorizontalSplitter UIOrganizer UIRect UIRenderer UIVerticalLister UIVerticalMultiSplitter UIVerticalSplitter ValueComboBox Window
EntityTransferrer FighterController Loot ReadOnlyEntityTransferrer ReadOnlyFighterController ReadOnlyLoot ReadOnlyTurretController ReadOnlyWreckageCreator TurretController WreckageCreator
Alliance [Server] Faction [Server] Galaxy [Server] Player [Server] ReadOnlySector Sector [Server] Server
AIState AlliancePrivilege BeamShape BlockShading BlockType BoxType ChatChannel ChatMessageType ComponentType ControlAction ControlActionBit CoolingType CrewProfessionType DamageSource DamageType DeletionType Difficulty EntityArrivalType EntityType FighterOrders FighterStartError FighterType FontType ImpactParticles InventoryItemType KeyboardKey ListBoxEntryType MalusReason MaterialType MoonType MouseButton PlanetType PlayerStateType ProjectileShape RarityType RelationStatus SavedDesignType SectorChangeType SoundType StatsBonuses TransformationFeature TurretAutoFireMode WeaponAppearance WeaponCategory
This is the official documentation for the scripting API of Avorion. This documentation is automatically generated and not necessarily complete. Depending on the context in which functions exist, some documentation such as descriptions, return values or variable names or types may be missing.
Work in Progress. Documentation of Avorion Version: 1.0 r22021 59065310fc1a